/*
 *  SableJBDD, a Java Binary Decision Diagram package.
 *  Copyright (C) 2003  Feng Qian
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
//$Id: RegularUniqueTable.java,v 1.1 2004/03/12 00:16:00 fqian Exp $

package SableJBDD.bdd.internal;

import SableJBDD.bdd.*;

import SableJBDD.bdd.util.HashFunction;

/**
 * A regular unique table is a hash table using regular references. It keeps all 
 * cached objects strongly reachable.
 *
 * @author Feng Qian
 */
public class RegularUniqueTable extends AbstractUniqueTable {
  /** 
   * Defines a unique table with a specific number of entries. 
   */
  public RegularUniqueTable(int size) {
    super(size);
  }               

  // Implements the abstract method of super class UniqueTable
  protected Element newElement(JBddNode node, Element next) {
    return new HardElement(node, next);
  }

  protected JBddNode makeNode(JBddVariable var, JBddNode low, JBddNode high) {
    return new JBddInternalNode(var, low, high);
  }

  // An element has a reference to a BddNode, and the link to 
  // the next element.
  class HardElement implements Element{
    private JBddNode node;
    private Element next;
    
    public HardElement(JBddNode node, Element next) {
      this.node = node;
      this.next = next;
    }
        
    // check if the soft reference is GCed.
    public boolean isEmpty() {
      return false;
    }
    
    public JBddNode getNode() {
      return this.node;
    }

    public Element getNext() {
      return this.next;
    }

    public void setNext(Element el) {
      this.next = el;
    }
  }  
}


